﻿
using System.Windows;
using System.Windows.Media;

namespace Cyl.ImageControl;

public abstract class ROI
{
    public Rect Bounds { get; set; }
    public double RotationAngle { get; set; } = 0;
    public Color Color { get; set; } = Colors.Red;

    public Point Center => new Point(Bounds.Left + Bounds.Width / 2, Bounds.Top + Bounds.Height / 2);
    public double Width => Bounds.Width;
    public double Height => Bounds.Height;

    public abstract void Draw(DrawingContext dc, double scale, Point offset);
    public abstract Point[] GetControlPoints();
    public abstract void UpdateControlPoint(Point controlPoint, Point newPosition);
    public abstract void Move(Point offset);

    protected void ApplyTransform(DrawingContext dc, double scale, Point offset)
    {
        var transformGroup = new TransformGroup();
        transformGroup.Children.Add(new ScaleTransform(scale, scale));
        transformGroup.Children.Add(new TranslateTransform(offset.X, offset.Y));
        dc.PushTransform(transformGroup);
    }
}
